﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HostpitalManage.GUI
{
    public partial class GoiDichVu : Form
    {
        public GoiDichVu()
        {
            InitializeComponent();
            LoadCombobox();
            LoadCheckedlistbox();
        }


        private void GoiDichVu_Load(object sender, EventArgs e)
        {
            
        }

        public void LoadCombobox()
        {
            DAO.Connection conn = new DAO.Connection();
            SqlConnection con = conn.conDB();
            con.Open();
            SqlCommand cm = new SqlCommand("Select distinct TenKhoa from BangGiaDichVu", con);
            SqlDataAdapter adt = new SqlDataAdapter(cm);
            DataSet ds = new DataSet();
            adt.Fill(ds);
            comboBox1.DataSource = ds.Tables[0];
            comboBox1.DisplayMember = "TenKhoa";
        }
        public void LoadCheckedlistbox()
        {
            String tenkhoa = comboBox1.Text;
            DAO.Connection conn = new DAO.Connection();
            SqlConnection con = conn.conDB();
            con.Open();
            SqlCommand cm = new SqlCommand("Select TenHienThi from BangGiaDichVu where TenKhoa = '" + tenkhoa + "' ", con);
            SqlDataAdapter adt = new SqlDataAdapter(cm);
            DataSet ds = new DataSet();
            adt.Fill(ds, "BangGiaDichVu");
            checkedListBox1.DataSource = ds.Tables[0];
            checkedListBox1.DisplayMember = "TenHienThi";
        }

        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            LoadCheckedlistbox();
        }
    }
}
